#include <bits/stdc++.h>

using namespace std;
const int maxn = 100;
int n, m;
int F[maxn];

int Find(int x) {
    return F[x] == x ? x : F[x] = Find(F[x]);
}

void Merge(int x, int y) {
    int fx = Find(x);
    int fy = Find(y);
    if (fx != fy) {
        F[fy] = fx;
    }
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        F[i] = i;
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        Merge(x, y);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (F[i] == i) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

/*
 input:

 10 9
 1 2
 3 4
 5 2
 4 6
 2 6
 8 7
 9 7
 1 6
 2 4

 output:

 3
 */
